﻿using Furion.DependencyInjection;
using Queer.AutoJob.Core.Entity;
using Queer.AutoJob.Core.Model;
using Queer.AutoJob.Core.Service;
using Queer.Util;
using Queer.Util.Model;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Queer.AutoJob.Core.Business
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2021-04-01 09:29
    /// 描 述：定时任务日志业务类
    /// </summary>

    public class AutoJobLogBLL : IAutoJobLogBLL, ITransient
    {
        private readonly IAutoJobLogService _autoJobLogService;

        public AutoJobLogBLL(IAutoJobLogService autoJobLogService)
        {
            _autoJobLogService = autoJobLogService;
        }

        #region 获取数据

        public async Task<TData<List<AutoJobLogEntity>>> GetList(AutoJobLogListParam param)
        {
            TData<List<AutoJobLogEntity>> obj = new TData<List<AutoJobLogEntity>>();
            obj.Data = await _autoJobLogService.GetList(param);
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<List<AutoJobLogEntity>>> GetPageList(AutoJobLogListParam param, Pagination pagination)
        {
            TData<List<AutoJobLogEntity>> obj = new TData<List<AutoJobLogEntity>>();
            obj.Data = await _autoJobLogService.GetPageList(param, pagination);
            obj.Total = pagination.TotalCount;
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<AutoJobLogEntity>> GetEntity(long id)
        {
            TData<AutoJobLogEntity> obj = new TData<AutoJobLogEntity>();
            obj.Data = await _autoJobLogService.GetEntity(id);
            obj.Tag = 1;
            return obj;
        }

        #endregion

        #region 提交数据

        public async Task<TData<string>> SaveForm(AutoJobLogEntity entity)
        {
            TData<string> obj = new TData<string>();
            await _autoJobLogService.SaveForm(entity);
            obj.Data = entity.Id.ParseToString();
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData> DeleteForm(string ids)
        {
            TData obj = new TData();
            await _autoJobLogService.DeleteForm(ids);
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData> DeleteFormByJobName(string jobName)
        {
            TData obj = new TData();
            await _autoJobLogService.DeleteFormByJobName(jobName);
            obj.Tag = 1;
            return obj;
        }

        #endregion
    }
}